home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.04 Apr 90 / Messenger Files / dDriver Folder / dDriver.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-09  |  2.7 KB  |  134 lines  |  [TEXT/KAHL]

  1. /* ==============================
  2.  
  3. Program name:  dDriver.c
  4. Function:  This is the main module for this program. 
  5. History: 10/3/89 by Kirk Chase. 
  6.  
  7. ================================= */
  8.  
  9. #include "String.h"
  10. #include "Messenger.h"
  11.   
  12. #define      NIL    0
  13.  
  14. /* External variables & routines */
  15.  
  16.  
  17. /* ====================================== */
  18. void main(void);
  19. /* ====================================== */
  20.  
  21. void main()
  22. {
  23. char    doneFlag;
  24. char    ch;
  25. short    code;
  26. short    theMenu,theItem;
  27. long    mResult;
  28. WindowPtr    whichWindow;
  29. EventRecord    myEvent;
  30. Rect    tempRect;
  31. GrafPtr    SavePort;
  32. int dummy;
  33.  
  34. MoreMasters();
  35. InitGraf(&thePort);
  36. InitFonts();
  37. FlushEvents(everyEvent,0);
  38. InitWindows();
  39. InitMenus();
  40. TEInit();
  41. InitDialogs(NIL);
  42. InitCursor();
  43.  
  44. OpenResFile("\pdDriver.π.RSRC");
  45.  
  46.  
  47. doneFlag = FALSE;
  48.  
  49. InitMyMenus();
  50.  
  51. InitMessage();
  52. dummy = ArrangeMessage(1);
  53.  
  54. do {
  55.     SystemTask();
  56.  
  57.     if (GetNextEvent(everyEvent, &myEvent))     {
  58.         code = FindWindow(myEvent.where, &whichWindow);    
  59.  
  60.         switch (myEvent.what) {
  61.             case mouseDown:
  62.                 if (code == inMenuBar) {
  63.                     mResult = MenuSelect(myEvent.where);
  64.                     theMenu = HiWord(mResult);
  65.                     theItem = LoWord(mResult);
  66.                     HandleMenu(&doneFlag,theMenu,theItem);
  67.                 }
  68.  
  69.                  if ((code == inDrag)&&(whichWindow != NIL)) {
  70.                      tempRect = screenBits.bounds;
  71.                      SetRect(&tempRect, tempRect.left + 10, tempRect.top + 25, tempRect.right - 10, tempRect.bottom - 10);
  72.                      DragWindow(whichWindow, myEvent.where, &tempRect);
  73.                 }
  74.  
  75.                 if (code == inContent) {
  76.                     if (whichWindow != FrontWindow()) {
  77.                         SelectWindow(whichWindow);
  78.                     } else {
  79.                         SetPort(whichWindow);
  80.                     }
  81.                 }
  82.  
  83.                 if (code == inSysWindow)
  84.                 {
  85.                     SystemClick(&myEvent, whichWindow);
  86.                 }
  87.                 break;
  88.  
  89.             case keyDown: 
  90.             case autoKey: 
  91.                 ch = myEvent.message &  charCodeMask;
  92.                 if (myEvent.modifiers & cmdKey) {
  93.                     mResult = MenuKey(ch);
  94.                     theMenu = HiWord(mResult);
  95.                     theItem = LoWord(mResult);
  96.                     if (theMenu != 0) 
  97.                         HandleMenu(&doneFlag, theMenu, theItem); 
  98.                 }
  99.                 break;
  100.  
  101.             case updateEvt:
  102.                 whichWindow = (WindowPtr)myEvent.message;
  103.                 GetPort(&SavePort);
  104.                 BeginUpdate(whichWindow);
  105.                 SetPort(whichWindow);
  106.                 
  107.                 EndUpdate(whichWindow);
  108.                 SetPort(SavePort);
  109.                 break;
  110.  
  111.             case diskEvt:
  112.                 if (HiWord(myEvent.message) != 0) {
  113.                     myEvent.where.h = ((screenBits.bounds.right - screenBits.bounds.left) / 2) - (304 / 2);
  114.                     myEvent.where.v = ((screenBits.bounds.bottom - screenBits.bounds.top) / 3) - (104 / 2);
  115.                     InitCursor();
  116.                     theItem = DIBadMount(myEvent.where, myEvent.message);
  117.                 }
  118.                 break;
  119.  
  120.             case activateEvt:
  121.                 if ((whichWindow != NIL) && (myEvent.modifiers & activeFlag)) { 
  122.                     SelectWindow(whichWindow);
  123.                 }
  124.                 break;
  125.  
  126.             default:
  127.                 break;
  128.  
  129.         }
  130.  
  131.     }
  132. } while (doneFlag ==  FALSE);
  133.  
  134. } /* end of main */